define([
  'jquery',
  'jqueryui',
  'underscore',
  'backbone',
  'text!templates/help/helpTemplate.html'
], function($,JQueryUI, _, Backbone, helpTemplate){

  var PatientHistoryView = Backbone.View.extend({
    el: $(".helpbox"),
    events: {/*'click #submitphistory' : 'submitphButton'*/
        } ,
    initialize: function(){
    	//_.bindAll(this, "changed");
    },
    render: function(){
    	this.helpcount=0
	      var compiledTemplate = _.template( helpTemplate, null );
  	      this.$el.html(compiledTemplate);
  	      $(".helpClose").click(function(){
  	    	$(".helpbox").hide();
  	    	$(".helparrow").hide();
  	      });
      	$(".helpbox").show();
    	$(".helparrow").show();
    	var self =this;

    	if($('#usertype').val()=='P'){
  	    	self.showHelpForPatient();
  	    	self.helpcount=self.helpcount+1;
  	      $(".helpNext").click(function(){
	  	    	self.showHelpForPatient();
	  	    	self.helpcount=self.helpcount+1;
	  	      });

    	}else if($('#usertype').val() =='D'){
    		self.showHelpForDoctor();
    		self.helpcount=self.helpcount+1;
  	      $(".helpNext").click(function(){
	  	    	self.showHelpForDoctor();
	  	    	self.helpcount=self.helpcount+1;
	  	      });

    	}

    },
    showHelpForPatient: function(){
		    switch(this.helpcount){
	    	case 0:
	    		$(".helpbox").css({top:"150px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
	        	$(".helparrow").css({top:"225px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
	        	$(".helpcontent span").html("Welcome to Appment. We would like to guide you thru the various features in the application so that you can take " +
	        			"maximum benefits! <br>\"News Feed\": You can access all your appointments and reports out here without any hassle!");
	    		break;
	    	case 1:
	    		$(".helpbox").css({top:"290px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
	        	$(".helparrow").css({top:"365px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
	        	$(".helpcontent span").html("This is one stop option to take appointment with any doctor of your preference. We do understand that" +
	        			"it is difficult to know the specialities so we have provided option where you can just put your problem and we will " +
	        			"show you the right doctors.");
	    		break;
	    	case 2:
	    		$(".helpbox").css({top:"430px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
	        	$(".helparrow").css({top:"505px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
	        	$(".helpcontent span").html("If you want to print some of your past reports, then you can use this option and do that");
	    		break;
	    	case 3:
	    		$(".helpbox").css({top:"550px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
	        	$(".helparrow").css({top:"625px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
	        	$(".helpcontent span").html("Appment can be of best benefit when you have the right information provided. If your phone number or" +
	        			"email has changed keep it updated here.");
	    		break;
	    	case 4:
	  	    	$(".helpbox").hide();
	  	    	$(".helparrow").hide();
	    		break;
	    }
    	
    },
    showHelpForDoctor: function(){
			    switch(this.helpcount){
		    	case 0:
		    		$(".helpbox").css({top:"150px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"225px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("Welcome to Appment. We would like to guide you thru the various features in the application so that you can take " +
		        			"maximum benefits! <br>\"News Feed\": You can access all your appointments and reports out here without any hassle!");
		    		break;
		    	case 1:
		    		$(".helpbox").css({top:"200px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"275px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("You can refer patient to specialist doctors using this option. Please provide the patient " +
		        			"phone and email so that Appment can help them with precare facility. That would help you gain patients confidence. " +
		        			"Please select the problem that patient has from available options.");
		    		break;
		    	case 2:
		    		$(".helpbox").css({top:"315px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"390px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("The very first thing to do after you have set up your consulting hospitals is to " +
		        			"set up your schedule. Once set, patients can search for you and take appointments");
		    		break;
		    	case 3:
		    		$(".helpbox").css({top:"415px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"490px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("We understand your workload and want to keep your typing to minimum. For this Appment " +
		        			"already has an Profile Engine, which suggests from some preset profiles which you can select to pre-populate " +
		        			"the tests. If you need some custom profiles that is not available by default but you use often, then use " +
		        			"this option to create one. It is one time activity and once done and saved next time you will get " +
		        			"the new profile to select!");
		    		break;
		    	case 4:
		    		$(".helpbox").css({top:"515px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"590px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("Lot of times patients come by reference. You can use Appment to ask Doctors to refer " +
		        			"patients. While they are referring, you can ensure that they select the right problem. This option helps you to customize what " +
		        			"problems can be selected while referring patient to you. Encourage Doctors to select this so that your preset precare " +
		        			"templates can be sent to patients. This will help you win their loyality.");
		    		break;
		    	case 5:
		    		$(".helpbox").css({top:"615px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"690px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("Sometimes you may want to look at complete patient history impromptu. This option helps you do that.");
		    		break;
		    	case 6:
		    		$(".helpbox").css({top:"715px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"790px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("Appment can be of best benefit when you have the right information provided. If your phone number or" +
		        			"email has changed keep it updated here.Also keep your specialities and hospitals where you work up-to-date " +
		        			"to allow patients to take appointments");
		    		break;
		    	case 7:
		    		$(".helpbox").css({top:"815px",left:$(".mainpanel").offset().left+75,'z-index':'999'});
		        	$(".helparrow").css({top:"890px",left:$(".mainpanel").offset().left-25,'z-index':'999'});
		        	$(".helpcontent span").html("This option provided a chart which gives your financial status. This is more of help when you use " +
		        			"Appment to bill patients.");
		    		break;
		    	case 8:
		  	    	$(".helpbox").hide();
		  	    	$(".helparrow").hide();
		    		break;
		    }
    	
    }
  });

  return PatientHistoryView;
});
